<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>Fancytree benchmarks</title>
	<script src="//code.jquery.com/jquery-3.6.0.min.js"></script>
	<script src="//code.jquery.com/ui/1.13.0/jquery-ui.min.js"></script>

	<link href="../../lib/qunit.css" rel="stylesheet" media="screen" />
	<script src="../../lib/qunit.js"></script>

	<link href="../../src/skin-win8/ui.fancytree.css" rel="stylesheet">
	<script src="../../src/jquery.fancytree.js"></script>
	<script src="../../src/jquery.fancytree.table.js"></script>

	<script src="test-tools.js"></script>
	<script src="test-bench.js"></script>

<style type="text/css">
table#tabletree {
	width: 100%;
	border-collapse: collapse;
}
table#tabletree td{
	border: 1px solid gray;
}
</style>
</head>
<body>
 <h1 id="qunit-header">Fancytree bencharks</h1>
 <h2 id="qunit-banner"></h2>
 <div id="qunit-testrunner-toolbar"></div>
 <h2 id="qunit-userAgent"></h2>
 <ol id="qunit-tests"></ol>
 <div id="qunit-fixture">test markup, will be hidden</div>
 <hr />
 <div id="tree"></div>
 <hr />
 <!-- Add a <table> element where the tree should appear: -->
 <table id="tabletree">
	<colgroup>
	<col width="50px"></col>
	<col width="*"></col>
	<col width="20px"></col>
	<col width="20px"></col>
	<col width="200px"></col>
	<col width="150px"></col>
	</colgroup>
	<thead>
		<tr> <th>#idx</th> <th>Node</th> <th>span</th> <th>icon</th> <th>text</th> <th>input</th> </tr>
	</thead>
	<tbody>
	</tbody>
 </table>

<script>
	// Beacon the results to Browserscope.
	// See: https://www.browserscope.org/user/tests/howto
	/*global QUnit */
	var _bTestResults = {},
		_testKey = "ahBzfnVhLXByb2ZpbGVyLWhychELEgRUZXN0GICAkNDcrYwJDA";


	// Timeout for async tests
	// QUnit.config.testTimeout = 1000;

	// Custom switch (could be used for a checkbox?)
	QUnit.config.publishResults = true;

	QUnit.moduleDone( function( details ) {
		var name = details.name;

		// window.console.log( "moduleDone", details );
		// make sure all assertions passed successfully
		if ( name === "Configuration and Summary" ) {
			return;
		}
		if ( !details.failed && details.total === details.passed ) {
			_bTestResults[ name ] = details.runtime;
		// _bTestResults[ name ] = 1
		} else {
			_bTestResults[ name ] = 0;
		}
	});

	// If the user agreed to publish results to BrowserScope.org, go for it!
	QUnit.done( function(details) {
		window.console.log( "done", arguments );
		_bTestResults[ "Overall::passed" ] = details.passed;
		_bTestResults[ "Overall::failed" ] = details.failed;
		_bTestResults[ "Overall::runtime" ] = details.runtime;
		if ( QUnit.config.publishResults ) {

			var newScript = document.createElement( "script" ),
				firstScript = document.getElementsByTagName( "script" )[ 0 ];

			newScript.src = "https://www.browserscope.org/user/beacon/" + _testKey + "?callback=showResults";
			// Set this to prevent throtteling
			// newScript.src += "&sandboxid=f87fe779e9a4375";
			// // newScript.src += "?test_results_var=YOUR-VAR-NAME2;

			firstScript.parentNode.insertBefore( newScript, firstScript );
		}
	});

	// Load the results widget from browserscope.org
	function showResults() {
		var script = document.createElement( "script" );

		script.src = "https://www.browserscope.org/user/tests/table/" + _testKey + "?o=js";

		// window.console.log( "showResults", arguments );
		document.body.appendChild( script );
		$( "table#tabletree, #tree" ).hide( "slow" );
	}

</script>
</body>
</html>
